<?php
/**
 * Author: Traveler
 * Time  : 2021/12/25 0025 15:56
 */

namespace app\validate;

use app\ErrorCode;
use think\Validate;

class IcafeValidate extends Validate
{
    /**
     * 验证规则
     *
     * @var string[]
     */
    protected $rule = [
        'name'        => 'require|max:16',
        'category_id' => 'require|integer|gt:0',
        'contact'     => 'require|max:16',
        'cellphone'   => 'require|mobile',
        'province_id' => 'require|integer|length:6',
        'city_id'     => 'require|integer|length:6',
        'district_id' => 'require|integer|length:6',
        'status'      => 'require|in:0,1',
    ];

    /**
     * 提示信息
     *
     * @var string[]
     */
    protected $message = [
        'name.require'        => ErrorCode::REQUIRE_ICAFE_NAME,
        'name.max'            => ErrorCode::INVALID_ICAFE_NAME_LEN,
        'category_id.require' => ErrorCode::REQUIRE_CATEGORY_ID,
        'category_id.integer' => ErrorCode::INVALID_CATEGORY_ID,
        'category_id.gt'      => ErrorCode::INVALID_CATEGORY_ID,
        'contact.require'     => ErrorCode::REQUIRE_CONTACT,
        'contact.max'         => ErrorCode::INVALID_CONTACT_LEN,
        'cellphone.require'   => ErrorCode::REQUIRE_CELLPHONE,
        'cellphone.mobile'    => ErrorCode::INVALID_CELLPHONE,
        'province_id.require' => ErrorCode::REQUIRE_REGION_ID,
        'province_id.integer' => ErrorCode::INVALID_REGION_ID,
        'province_id.length'  => ErrorCode::INVALID_REGION_ID,
        'city_id.require'     => ErrorCode::REQUIRE_REGION_ID,
        'city_id.integer'     => ErrorCode::INVALID_REGION_ID,
        'city_id.length'      => ErrorCode::INVALID_REGION_ID,
        'district_id.require' => ErrorCode::REQUIRE_REGION_ID,
        'district_id.integer' => ErrorCode::INVALID_REGION_ID,
        'district_id.length'  => ErrorCode::INVALID_REGION_ID,
        'status.require'      => ErrorCode::REQUIRE_ICAFE_STATUS,
        'status.in'           => ErrorCode::INVALID_ICAFE_STATUS,
    ];
}